<template>
    <div class="searchBar" id="run_searchBar">
        <div class="navBar">
            <ul>
                <li :class="props.activeIndex == 0 ? 'active' : ''" @click="changeNav(0)">
                    <span>运行班组会议</span>
                </li>
                <li class="userType" :class="props.activeIndex == 1 ? 'active' : ''" @click="changeNav(1)">
                    <span>检修班组会议</span>
                </li>
            </ul>
        </div>
        <div class="topWrapper">
            <div class="left">
                <el-form class="form" label-position="left" @submit.native.prevent>
                    <el-form-item label="主持人">
                        <el-input v-model.trim="searchData.params.createName" placeholder="主持人" clearable></el-input>
                    </el-form-item>
                    <el-form-item label="班组">
                        <el-select v-model="searchData.params.type" class="m-2" placeholder="班组" clearable>
                            <el-option label="锅炉一值" :value="1" />
                            <el-option label="锅炉二值" :value="2" />
                        </el-select>
                    </el-form-item>
                    <el-form-item label="班会类型">
                        <el-select v-model="searchData.params.type" class="m-2" placeholder="班会类型" clearable>
                            <el-option label="班前会" :value="1" />
                            <el-option label="班会后" :value="2" />
                        </el-select>
                    </el-form-item>
                    <el-form-item label="召开日期">
                        <el-date-picker style="width: 260px;" v-model="receiptTime" type="daterange" range-separator="-"
                            start-placeholder="开始日期" end-placeholder="结束日期" format="YYYY/MM/DD"
                            value-format="YYYY-MM-DD" @change="changeReceiptTime" :disabled-date="disabledDate"
                            unlink-panels />
                        <!-- <el-input v-model.trim="searchData.params.name" placeholder="操作时间" clearable></el-input> -->
                    </el-form-item>
                </el-form>
            </div>
            <div class="right">
                <div class="btn_bg" title="搜索" @click="searchList">
                    <img class="btn_icon search_icon" src="@/assets/images/images_new/search_icon.png" alt="">
                </div>
                <div class="btn_bg btn_bg2" title="清空" @click="emptySearch">
                    <img class="btn_icon reset_icon" src="@/assets/images/images_new/reset_icon.png" alt="">
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
const props = defineProps({
    activeIndex: {
        type: Number,
        default: 0
    },
    table_height: {
        type: Number,
        default: 0
    },
})

// 页码及搜索数据
let searchData = reactive({
    pageNum: 1, //当前页
    pageSize: 10, //每页条目数
    params: {
        content: '', // 变更内容
        createName: '', // 操作人
        createTimeEnd: '', // 操作时间结束
        createTimeStart: '', // 操作时间开始
        spaceId: '', // 房间/工位id
        type: '', // 变更类型(1-新增,2-编辑,3-删除,4-导入
    }
})

const receiptTime = ref('') as any;//接收时间

const changeReceiptTime = (val: string[]) => {
    console.log('val', val);
    if (val && val.length == 2) {
        searchData.params.createTimeStart = val[0] + " 00:00:00";
        searchData.params.createTimeEnd = val[1] + " 23:59:59";
    } else {
        searchData.params.createTimeStart = "";
        searchData.params.createTimeEnd = "";
    }
}

const disabledDate = (time: any) => {
    return time.getTime() > Date.now(); // 8.64e7 毫秒数代表一天
}

//搜索
const searchList = () => {
    console.log('151');
    // getList(); //更新表格列表
}

//清空
const emptySearch = () => {
    searchData.params = {
        content: '', // 变更内容
        createName: '', // 操作人
        createTimeEnd: '', // 操作时间结束
        createTimeStart: '', // 操作时间开始
        spaceId: '', // 房间/工位id
        type: '', // 变更类型(1-新增,2-编辑,3-删除,4-导入
    };
    receiptTime.value = "";
    // getList(); //更新表格列表
}

//emit(父组件中的自定义方法)
const emit = defineEmits(['changeNav']);

//切换导航栏
const changeNav = (val: number) => {
    if (val != props.activeIndex) {
        emit('changeNav', val)
    }

}
</script>


<style lang="scss" scoped>
.searchBar {
    background-color: #fff;
    border-radius: 0 0 8px 8px;
    padding: 28px 28px 20px 30px;
    // height: 80px;
    height: 146px;

    .navBar {
        ul {
            // width: 320px;
            display: flex;
            // border: 1px solid rgb(229, 229, 229);

            li {
                width: 160px;
                height: 38px;
                font-size: 16px;
                font-weight: 400;
                letter-spacing: 0px;
                line-height: 36px;
                // color: rgba(0, 0, 0, 1);
                color: rgb(112, 105, 95);
                text-align: center;
                cursor: pointer;
                position: relative;
                border-top: 1px solid rgb(229, 229, 229);
                border-bottom: 1px solid rgb(229, 229, 229);

                // border-right: 1px solid rgb(229, 229, 229);
                &:first-child {
                    border-left: 1px solid rgb(229, 229, 229);
                }

                &:last-child {
                    border-right: 1px solid rgb(229, 229, 229);
                }

                &.userType {
                    border-left: 1px solid rgb(229, 229, 229);
                    border-right: 1px solid rgb(229, 229, 229);
                }

                &.active {
                    width: 160px;
                    font-size: 16px;
                    line-height: 36px;
                    color: rgba(0, 0, 0, 1);
                    background: rgb(229, 229, 229);
                    // border: 1px solid rgba(0, 0, 0, 0);

                }
            }

        }
    }

    .topWrapper {
        display: flex;
        width: 100%;
        padding-left: 8px;
        margin-top: 26px;
        flex-wrap: wrap;

        .left {
            flex: 1;
            display: flex;
            flex-wrap: wrap;
            flex-shrink: 1;
            min-width: 0;


            .el-form {
                display: flex;
                flex-wrap: wrap;

                .el-form-item {

                    max-width: 25%;
                    padding-right: 30px;

                    // &.treeList {
                    //     width: 40%;
                    // }
                    :deep(.select-trigger) {
                        .el-input {
                            width: 100%;
                        }
                    }

                    :deep(.el-cascader) {
                        width: 260px;

                        .el-input {
                            width: 100%;
                        }
                    }
                }
            }
        }

        .right {
            width: 87px;
            height: 32px;
            flex-shrink: 0;
            display: flex;
            justify-content: flex-start;
            align-items: center;

            .btn_bg {

                height: 35px;
                width: 35px;
                display: flex;
                justify-content: center;
                align-items: center;
                cursor: pointer;

                &:hover {
                    background: rgba(0, 0, 0, 0.1);
                    border-radius: 2px;
                }

                &.btn_bg2 {
                    margin-left: 17px;
                }

                .search_icon {
                    width: 21px;
                }

                .reset_icon {
                    width: 20px;
                    cursor: pointer;
                }
            }


        }
    }
}
</style>